<include file="Public/head"/>
<body class="no-skin">
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->


            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <div class="row">
                    <div class="col-sm-9">
                                    <textarea name="content" id="content" style="color: red" placeholder=""
                                              class="col-xs-10 col-sm-5" rows="5">{$message}</textarea>
                        <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                    </div>

                </div>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">



                        <!-- PAGE CONTENT BEGINS -->
                        <form id="query" class="form-inline" action="{:U('lists')}" method="get">
                            <div class="row">

                                <label class="inline">工单号</label>
                                <input type="text" name="order_no" value="{:I(order_no)}" class="form-control">
                                <label class="inline">订单来源</label>
                                <input type="text" name="source" value="{:I(source)}" class="form-control">
                                <label class="inline">游戏账号</label>
                                <input type="text" name="game_user" value="{:I(game_user)}" class="form-control">
                                <label class="inline">手机</label>
                                <input type="text" name="mobile" value="{:I(mobile)}" class="form-control">
                            </div>
                            <div class="row">
                                <label class="inline">时间</label>
                                <input class="form-control dates" name="time" value="{:I('time',date('Y-m-d'))}"
                                       type="text" data-date-format="dd-mm-yyyy">

                                <!--<input class="form-control dates" name="create_end" value="" type="text" data-date-format="dd-mm-yyyy">-->


                                <!--<label class="inline">处理时间</label>-->
                                <!--<input class="form-control dates"  name="dispose_start" value="" type="text" data-date-format="dd-mm-yyyy">-->
                                <!-- - -->
                                <!--<input class="form-control dates" name="dispose_end" value="" type="text" data-date-format="dd-mm-yyyy">-->


                                <label class="inline">状态</label>
                                <select name="status" class="form-control">
                                    <option
                                    <if condition="I('status') eq null">selected</if>
                                    value="">全部</option>
                                    <foreach name="statusList" item="status" key="statusKey">
                                        <option
                                        <if condition="I('status') eq $statusKey">selected</if>
                                        value="{$statusKey}" >{$status.title}</option>
                                    </foreach>
                                </select>


                                <label class="inline">客服一</label>
                                <select name="dispose_user" class="form-control">
                                    <option
                                    <if condition="I('dispose_user') eq null">selected</if>
                                    value="">全部</option>
                                    <foreach name="member" item="mb">
                                        <option
                                        <if condition="I('dispose_user') eq $mb[user]">selected</if>
                                        value="{$mb.user}" >{$mb.user}</option>
                                    </foreach>
                                </select>
                                <label class="inline">客服二</label>
                                <select name="dispose_user2" class="form-control">
                                    <option
                                    <if condition="I('dispose_user2') eq null">selected</if>
                                    value="">全部</option>
                                    <foreach name="member" item="mb">
                                        <option
                                        <if condition="I('dispose_user2') eq $mb[user]">selected</if>
                                        value="{$mb.user}" >{$mb.user}</option>
                                    </foreach>
                                </select>
                                <label class="inline">是否售后</label>
                                <select name="is_aftersale" class="form-control">
                                    <option
                                    <if condition="I('is_aftersale') eq null">selected</if>
                                    value="">全部</option>
                                        <option <if condition="I('is_aftersale') eq 2">selected</if>
                                        value="2" >否</option>
                                    <option <if condition="I('is_aftersale') eq 1">selected</if>
                                    value="1" >是</option>

                                </select>

                                <button type="submit" class="btn btn-purple btn-sm">
                                    <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
                                    查询
                                </button>
                                <button onclick="location=location" type="button" class="btn btn-purple btn-sm">
                                    <span class="ace-icon fa fa-globe  icon-on-right bigger-110"></span>
                                    刷新
                                </button>

                                <button onclick="exportOrder()" type="button" class="btn btn-purple btn-sm">
                                    <span class="ace-icon fa fa-cloud-download icon-on-right bigger-110"></span>
                                    下载
                                </button>

                            </div>
                        </form>
                        <div class="space-4"></div>
                        <div class="row">
                            <form id="form" method="post" action="{:U('del')}">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <!--<th class="center"><input class="check-all" type="checkbox" value=""></th>-->
                                        <th>工单号</th>
                                        <th>客户账号</th>
                                        <th>订单来源</th>
                                        <th>手机</th>
                                        <th>创建时间</th>
                                        <th>用户备注</th>
                                        <th>客服一</th>
                                        <th>客服二</th>
                                        <th>最后处理时间</th>
                                        <th>售后</th>
                                        <th class="center">状态</th>
                                        <th>备注</th>
                                        <th class="center">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <style>
                                        .grouptd {
                                            position: relative;
                                        }

                                        .group {
                                            display: inline-block;
                                            width: 100%;
                                        }

                                        .groupselect {
                                            position: absolute;
                                            top: 0;
                                            left: 0;
                                            width: 100%;
                                            height: 100%;
                                            border: 0;
                                        }
                                    </style>
                                    <volist name="list" id="val">
                                        <tr>
                                            <!--<td class="center">-->
                                            <!--<input class="uids" type="checkbox" name="uids[]" value="{$val['uid']}">-->
                                            <!--</td>-->
                                            <td> {$val.order_no}</td>
                                            <td> {$val.game_user}</td>
                                            <td> {$val.source}</td>
                                            <td> {$val.mobile}</td>
                                            <td> {$val.create_date}</td>
                                            <td> {$val.user_remark}</td>
                                            <td> {$val.dispose_user}</td>
                                            <td> {$val.dispose_user2}</td>
                                            <td> {$val.dispose_date}</td>
                                            <td> {$val.is_aftersale|sf_to_str=###}</td>

                                            <td>
                                                <span class="label label-{$val.status|os_to_str=###,'class'}">{$val.status|os_to_str=###,'title'}</span>
                                            </td>
                                            <td> {$val.dispose_remark}</td>
                                            <td class="center">
                                                <!--显示不关闭订单-->
                                                <if condition="$val[status] neq $closeStatus">
                                                    <!--判断是否第一客服-->
                                                    <if condition="$roleId eq $FIRST_ROLE ">
                                                        <if condition="$val[dispose_user] eq  $user OR $val[dispose_user] eq null">
                                                            <foreach name="statusList" item="status" key="statusKey">
                                                                <if condition="$statusKey neq $val[status]">
                                                                    <a href="{:U('changeOrderStatus', array('status'=>$statusKey, 'id'=>$val[id]))}"
                                                                       class="btn btn-xs btn-{$status.class}" type="button">{$status.title}</a>
                                                                </if>
                                                            </foreach>
                                                            <a href="javascript:window.parent.openapp('{:U("editOrder",
                                                            array( "id"=>$val[id]))}',
                                                            '{$val.order_no}','{$val.order_no}工单详情',true) " class="btn
                                                            btn-xs" type="button" >修改</a>

                                                        </if>
                                                    </if>

                                                    <!--第二客服-->

                                                    <if condition="$roleId eq $SECOND_ROLE ">

                                                            <foreach name="statusList" item="status" key="statusKey">
                                                                <if condition="$statusKey neq $val[status]">
                                                                    <a href="{:U('changeOrderStatus', array('status'=>$statusKey, 'id'=>$val[id]))}"
                                                                       class="btn btn-xs btn-{$status.class}" type="button">{$status.title}</a>
                                                                </if>
                                                            </foreach>
                                                            <a href="javascript:window.parent.openapp('{:U("editOrder",
                                                            array( "id"=>$val[id]))}',
                                                            '{$val.order_no}','{$val.order_no}工单详情',true) " class="btn
                                                            btn-xs" type="button" >修改</a>
                                                    </if>

                                                    <!--超级管理员-->
                                                    <if condition="$roleId eq $ROOT_ROLE ">

                                                        <foreach name="statusList" item="status" key="statusKey">
                                                            <if condition="$statusKey neq $val[status]">
                                                                <a href="{:U('changeOrderStatus', array('status'=>$statusKey, 'id'=>$val[id]))}"
                                                                   class="btn btn-xs btn-{$status.class}" type="button">{$status.title}</a>
                                                            </if>
                                                        </foreach>
                                                        <a href="javascript:window.parent.openapp('{:U("editOrder",
                                                        array( "id"=>$val[id]))}',
                                                        '{$val.order_no}','{$val.order_no}工单详情',true) " class="btn
                                                        btn-xs" type="button" >修改</a>
                                                    </if>
                                                </if>

                                            </td>
                                        </tr>
                                    </volist>
                                    </tbody>
                                </table>
                            </form>
                            <div class="cf">

                            </div>
                            {$page}
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {
        $(".group").click(function () {
            $(this).addClass('hide');
            $(this).parent().find(".groupselect").removeClass('hide');
        })
        $(".groupselect").on("change", function () {
            var ob = $(this);
            var gid = ob.val();
            var uid = ob.parent().find('.group').attr('val');
            $.get("{:U('update')}?ajax=yes&uid=" + uid + "&gid=" + gid, function (data) {
                var text = ob.find("option:selected").text();
                ob.parent().find(".group").removeClass('hide').html(text);
                ob.addClass('hide');
            });
        })

        $(".check-all").click(function () {
            $(".uids").prop("checked", this.checked);
        });
        $(".uids").click(function () {
            var option = $(".ids");
            option.each(function (i) {
                if (!this.checked) {
                    $(".check-all").prop("checked", false);
                    return false;
                } else {
                    $(".check-all").prop("checked", true);
                }
            });
        });
        $("#submit").click(function () {
            bootbox.confirm({
                title: "系统提示",
                message: "是否要删除所选用户？",
                callback: function (result) {
                    console.log(result)
//                    if (result) {
//                        $("#form").submit();
//                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
        $(".del").click(function () {
            var url = $(this).attr('val');
            bootbox.confirm({
                title: "系统提示",
                message: "是否要删除该用户?",
                callback: function (result) {
                    if (result) {
                        window.location.href = url;
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
    })
</script>


<script src="__PUBLIC__/qwadmin/js/date-time/bootstrap-datepicker.js"></script>
<script src="__PUBLIC__/qwadmin/js/function.js"></script>
<script type="text/javascript">
    jQuery(function ($) {
        $('.dates').datepicker({
            format: 'yyyy-mm-dd',
            weekStart: 1,
            autoclose: true,
            todayBtn: 'linked',
            language: 'cn'
        });
    });
</script>

<script>
    function exportOrder() {
        var data = $('#query');
        var tmpInput = $("<input id='exportOrder' type='hidden' name='exportOrder' value='1'/>");
        data.append(tmpInput);
        data.submit();
        $('#exportOrder').remove()
    }
</script>
</body>
</html>
